---
title: "VAMP Planning Request Lifecycle - Complete Flow"
---
sequenceDiagram
    participant User as User Application
    participant API as executeMotionPlanning()
    participant RR as RobotRegistry
    participant VOP as VampOMPLPlanner
    participant OPC as OMPLPlanningContext
    participant SI as OMPL SpaceInformation
    participant VSV as VampStateValidator
    participant VMV as VampMotionValidator
    participant VE as VectorizedEnvironment
    participant PF as PlannerFactory
    participant PLANNER as OMPL Planner
    participant PD as ProblemDefinition
    
    %% Configuration Phase
    User->>API: executeMotionPlanning(config)
    API->>API: validate configuration
    API->>RR: getInstance()
    API->>RR: createRobotConfig(name, start, goal)
    RR->>RR: lookup robot handler
    RR-->>API: robot configuration
    
    API->>API: createEnvironmentFactory(obstacles)
    API->>RR: createPlanner(name, config, factory)
    RR->>VOP: new VampOMPLPlanner(config, factory)
    VOP-->>RR: planner instance
    RR-->>API: planner
    
    %% Initialization Phase
    API->>RR: initializePlanner(name, planner)
    RR->>VOP: initialize()
    
    %% Environment Setup
    VOP->>VOP: createEnvironment()
    VOP->>VE: VectorizedEnvironment(scalarEnv)
    VE->>VE: vectorize obstacles (AOS→SOA)
    VE-->>VOP: vectorized environment
    
    %% OMPL Setup
    VOP->>OPC: setupStateSpace(robotConfig, venv)
    OPC->>SI: new SpaceInformation(realVectorSpace)
    OPC->>SI: setBounds(jointLimits)
    
    %% Validator Setup
    OPC->>VSV: new VampStateValidator(si, venv)
    OPC->>VMV: new VampMotionValidator(si, venv)
    OPC->>SI: setStateValidityChecker(validator)
    OPC->>SI: setMotionValidator(validator)
    OPC->>SI: setup()
    SI-->>OPC: configured space info
    
    %% Problem Definition
    OPC->>PD: new ProblemDefinition(si)
    OPC->>PD: setStartAndGoalStates(start, goal)
    OPC->>PD: setOptimizationObjective(pathLength)
    PD-->>OPC: configured problem
    
    VOP-->>RR: initialization complete
    RR-->>API: ready
    
    %% Planning Execution
    API->>RR: executePlanning(name, planner, config)
    RR->>VOP: plan(config)
    VOP->>OPC: plan(config)
    
    %% Planner Creation
    OPC->>PF: createPlannerByName(name)
    PF->>PF: lookup factory function
    PF->>PLANNER: factory(spaceInformation)
    PLANNER-->>PF: planner instance
    PF-->>OPC: planner
    
    %% Planner Setup
    OPC->>PLANNER: setProblemDefinition(pdef)
    OPC->>PLANNER: setup()
    
    %% Main Planning Loop
    OPC->>PLANNER: solve(timeout)
    
    loop Planning iterations
        PLANNER->>SI: sample random state
        PLANNER->>VSV: isValid(state)
        VSV->>VSV: ompl_to_vamp(state)
        VSV->>VE: validate_motion(config, config)
        
        Note over VE: SIMD collision detection<br/>8x parallel processing
        VE->>VE: vectorized collision check
        VE-->>VSV: collision result
        VSV-->>PLANNER: validity result
        
        PLANNER->>SI: extend tree/graph
        PLANNER->>VMV: checkMotion(state1, state2)
        VMV->>VMV: ompl_to_vamp(states)
        VMV->>VE: validate_motion(start, end, resolution)
        
        Note over VE: "Rake" motion validation<br/>Parallel sampling across SIMD lanes
        VE->>VE: vectorized motion check
        VE-->>VMV: motion result
        VMV-->>PLANNER: validity result
    end
    
    PLANNER-->>OPC: PlannerStatus::EXACT_SOLUTION
    
    %% Solution Processing
    OPC->>PD: getSolutionPath()
    PD-->>OPC: solution path
    OPC->>OPC: calculate initial cost
    
    %% Path Simplification (optional)
    alt simplification requested
        OPC->>OPC: PathSimplifier.simplify(path, time)
        OPC->>OPC: calculate final cost
    end
    
    OPC-->>VOP: PlanningResult
    
    %% Path Writing (optional)
    alt write_path enabled
        VOP->>VOP: writeOptimizedSolutionPath()
        VOP->>VOP: interpolate path waypoints
        VOP->>VOP: generate filename
        VOP->>VOP: write path matrix to file
        VOP-->>VOP: solution file path
    end
    
    VOP-->>RR: PlanningResult
    RR-->>API: PlanningResult
    API-->>User: MotionPlanningResult
    
    %% Performance Notes
    Note over VSV, VE: Zero-copy state conversion<br/>Function-local static buffer pools
    Note over VMV, VE: SIMD "rake" sampling<br/>8x collision checks per call
    Note over VE: Structure-of-Arrays layout<br/>Cache-optimized memory access
